package cn.qidisoft.edu.hzjt.service.zyc.impl;

import java.util.List;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.qidisoft.core.common.code.QdfRespCode;
import cn.qidisoft.core.common.exception.dao.DBException;
import cn.qidisoft.core.common.log.LoggerAdapter;
import cn.qidisoft.core.common.log.LoggerAdapterFactory;
import cn.qidisoft.core.common.pagination.Page;
import cn.qidisoft.core.common.pagination.PaginationBean;
import cn.qidisoft.edu.hzjt.dao.zyc.DevelopmentPlanningAttMapper;
import cn.qidisoft.edu.hzjt.model.zyc.DevelopmentPlanning;
import cn.qidisoft.edu.hzjt.model.zyc.DevelopmentPlanningAtt;
import cn.qidisoft.edu.hzjt.model.zyc.SchoolMagazineAtt;
import cn.qidisoft.edu.hzjt.service.zyc.IDevelopmentPlanningAttService;
import cn.qidisoft.edu.hzjt.utils.LogType;

@Service
public class DevelopmentPlanningAttServiceImpl implements IDevelopmentPlanningAttService{


    protected static final LoggerAdapter LOGGER = LoggerAdapterFactory
            .getLogger(LogType.HZJT_LOGGER.val);

	
	
    @Autowired
    private DevelopmentPlanningAttMapper developmentPlanningAttMapper;
	
    @Override
    public List<DevelopmentPlanningAtt> queryList(DevelopmentPlanningAtt schoolMagazineAtt) {
        return developmentPlanningAttMapper.queryList(schoolMagazineAtt);
    }

    @Override
    public PaginationBean<DevelopmentPlanningAtt> queryPageList(DevelopmentPlanningAtt data, Page page) {
        try {
            int c = developmentPlanningAttMapper.queryPageListcount(data);
            int totalRecords = c;
            PaginationBean<DevelopmentPlanningAtt> pageHolder = new PaginationBean<>(page, totalRecords);
            List<DevelopmentPlanningAtt> resultList = developmentPlanningAttMapper
                    .queryPageList(data,
                            new RowBounds((pageHolder.getCurrentPage() - 1) * pageHolder.getPageSize(),
                                    pageHolder.getPageSize()));
            pageHolder.setPageList(resultList);
            return pageHolder;
        } catch (Exception e) {
            LOGGER.error("queryPageList [{}] error," + this.getClass().getName() + "=[{}]",
                    this.getClass().getName(),
                    ToStringBuilder.reflectionToString(data, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                    e);
        }
    }

    public DevelopmentPlanningAtt queryByPK(DevelopmentPlanningAtt record) {
        return developmentPlanningAttMapper.queryByPK(record);
    }

    @Override
    public String insert(DevelopmentPlanningAtt record) {
    	developmentPlanningAttMapper.insert(record);
        return "";
    }

    @Override
    public void batchInserts(List<DevelopmentPlanningAtt> records) {
    	developmentPlanningAttMapper.batchInserts(records);
    }

    @Override
    public int update(DevelopmentPlanningAtt record) {
    	developmentPlanningAttMapper.update(record);
        return 0;
    }

    @Override
    public int delete(DevelopmentPlanningAtt record) {
    	developmentPlanningAttMapper.delete(record);
        return 0;
    }

    @Override
    public int validation(DevelopmentPlanningAtt record) {
        return developmentPlanningAttMapper.validation(record);
    }

	@Override
	public List<DevelopmentPlanningAtt> getPlanningAtt(DevelopmentPlanning development) {
		
		return developmentPlanningAttMapper.getPlanningAtt(development);
	}

	@Override
	public DevelopmentPlanningAtt queryByFileId(DevelopmentPlanningAtt attEntity) {
		
		return developmentPlanningAttMapper.queryByFileId(attEntity);
	}

	@Override
	public void deleteAccessory(DevelopmentPlanningAtt attEntity) {
		developmentPlanningAttMapper.deleteAccessory(attEntity);
		
	}



}
